package org.example.common;

import lombok.Data;

@Data
public class ResponseData<T> {
    // 响应码
    private String code;
    // 相应消息
    private String message;
    // 数据
    private T data;

    public ResponseData(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResponseData(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public static <T> ResponseData<T> success(T data){
        return new ResponseData<T>(ResponseEnum.OK.getCode(),ResponseEnum.OK.getMessage(),data);
    }
    public static <T> ResponseData<T> success(){
        return new ResponseData<T>(ResponseEnum.OK.getCode(),ResponseEnum.OK.getMessage());
    }

    public static<T> ResponseData<T> fail(){
        return new ResponseData<T>(ResponseEnum.Fail.getCode(),ResponseEnum.Fail.getMessage());
    }
    public static<T> ResponseData<T> fail(String message){
        return new ResponseData<T>(ResponseEnum.Fail.getCode(),message);
    }


}


